﻿using UnityEngine;

namespace ProjectSurvival
{
    public class DamageSystem
    {
        public static void CalculateDamage(float baseDamage, IEnemy enemy, int maxNormalDamage = 2,
            float criticalDamageTimes = 5)
        {
            baseDamage *= Global.DamageRate.Value;
            if (Random.Range(0,1f)<Global.CriticalRate.Value)
            {
                enemy.Hurt(baseDamage*Random.Range(2,criticalDamageTimes),false,true);
            }
            else
            {
                enemy.Hurt(baseDamage+Random.Range(-1,maxNormalDamage));
            }
        }
    }
}